

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Brand{
	private String name;
	
	public Brand(String name) {
		super();
		this.name = name;
	}
	
@Override
	public String toString() {
		return "Brand [name=" + name + "]";
	}

}


class Car{

	private static int id=0;
	private Brand brand;
	
	static{
		
		System.out.println("0 car");
	}
	
	public Car(Brand brand) {
		super();
		this.brand = brand;
	}
	
@Override
	public String toString() {
		++id;
		return "Car [id=" + id + ", brand=" + brand.toString() + "]";
	}

}

public class Test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		Brand[] brands=new Brand[n];
		Car[] cars=new Car[n];
		int j=0;
		for(int i=0;i<n;i++){
			String str=in.nextLine();
			if(cars.equals(str)){
				System.out.println(str+" exist");
				continue;
			}
			brands[j]=new Brand(str);
			cars[j]=new Car(brands[j]);
			j++;
		}
		in.close();
		for(int i=1;i<j;i++){
			System.out.println(cars[i].toString());
		}
		System.out.println(Arrays.toString(Car.class.getConstructors()));
	}

}
